package com.qwiki.text;

import java.util.Collections;
import java.util.List;

/**
 * @author xgu
 * 
 * @since Jun 9, 2012
 */
public class MathNode extends Node
{
  private static String startMath = "<math>";
  private static String endMath = "</math>";

  @Override
  public String getText()
  {
    return " ";
  }

  @Override
  public List<Node> getChildren()
  {
    return Collections.EMPTY_LIST;
  }

  @Override
  public boolean parse(char[] buffer, int start)
  {
    this.start = start;
    this.buffer = buffer;
    int i = start;
    if (match(buffer, start, startMath))
    {
      i += startMath.length();
      while (i < buffer.length)
      {
        // parse end of MathNode
        if (match(buffer, i, endMath))
        {
          end = i + endMath.length();
          parsed = true;
          return true;
        }
        i++;
      }
    }
    return false;
  }
}
